﻿<Window x:Class="NetWebScript.Debug.App.ProgramWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalon="http://icsharpcode.net/sharpdevelop/avalonedit"
        xmlns:l="clr-namespace:NetWebScript.Debug.App.Controls"
        Title="" Height="700" Width="900">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary 
                  Source="Controls/TreeListView.xaml">
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100" Width="0.3*" />
            <ColumnDefinition Width="3" />
            <ColumnDefinition MinWidth="100" Width="0.7*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TreeView Grid.Column="0" x:Name="tree" ItemsSource="{Binding SourceFiles}">
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <EventSetter Event="MouseDoubleClick" Handler="OpenFile" />
                </Style>
            </TreeView.ItemContainerStyle>
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                    <TextBlock Text="{Binding Name}" />
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>

        <GridSplitter Grid.ZIndex="1" Grid.Column="1" BorderThickness="5,0" HorizontalAlignment="Center" VerticalAlignment="Stretch" BorderBrush="Transparent" />

        <DockPanel Grid.Column="2">
        
            <StackPanel DockPanel.Dock="Top"  Orientation="Horizontal">
                <Button Click="Continue">Continue</Button>
                <Button Click="StepOver">Step over</Button>
                <Button Click="StepIn">Step in</Button>
                <Button Click="StepOut">Step out</Button>
            </StackPanel>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition MinHeight="100" Height="0.8*" />
                    <RowDefinition Height="3" />
                    <RowDefinition MinHeight="100" Height="0.2*" />
                </Grid.RowDefinitions>

                <avalon:TextEditor Grid.Row="0" ShowLineNumbers="True"  IsReadOnly="True" FontFamily="Consolas" SyntaxHighlighting="C#" FontSize="10pt" Margin="5" x:Name="editor" />

                <GridSplitter Grid.ZIndex="1" Grid.Row="1" BorderThickness="0,5" VerticalAlignment="Center" HorizontalAlignment="Stretch" BorderBrush="Transparent" />

                <TabControl Grid.Row="2">
                    <TabItem Header="Breakpoints">
                        <ListView SelectedValuePath="." ItemsSource="{Binding ActivePoints}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Header="File" Width="300" DisplayMemberBinding="{Binding FileName}" />
                                    <GridViewColumn Header="Line" DisplayMemberBinding="{Binding StartRow}" />
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </TabItem>
                    <TabItem Header="Call stack">
                        <ListView SelectedValuePath="." ItemsSource="{Binding CurrentBreakedThreadStack.Frames}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Header="Method" DisplayMemberBinding="{Binding DisplayName}" Width="600" />
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </TabItem>
                    <TabItem Header="Locals">
                        <!--<ListView SelectedValuePath="." ItemsSource="{Binding CurrentBreakedThreadStack.Frames[0].Locals.Children}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Header="Name" DisplayMemberBinding="{Binding DisplayName}" />
                                    <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Value}" />
                                    <GridViewColumn Header="Type" DisplayMemberBinding="{Binding ValueTypeDisplayName}" />
                                </GridView>
                            </ListView.View>
                        </ListView>-->
                        <l:TreeListView ItemsSource="{Binding CurrentBreakedThreadStack.Frames[0].Locals.Children}">
                            <l:TreeListView.Columns>
                                <GridViewColumn Header="Name" CellTemplate="{StaticResource CellTemplate_Name}" Width="175" />
                                <!--<GridViewColumn Header="Name" DisplayMemberBinding="{Binding DisplayName}" />-->
                                <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Value}" Width="325" />
                                <GridViewColumn Header="Type" DisplayMemberBinding="{Binding ValueTypeDisplayName}" Width="100" />
                            </l:TreeListView.Columns>
                            <l:TreeListView.ItemTemplate>
                                <HierarchicalDataTemplate ItemsSource="{Binding Children}" />
                            </l:TreeListView.ItemTemplate>
                        </l:TreeListView>
                    </TabItem>
                </TabControl>
                
            </Grid>

        </DockPanel>
        
    </Grid>
</Window>
